/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Alejo
 */
class huffmanTree implements Comparable<huffmanTree>
{
BinaryTree<node> empty = null;
BinaryTree<node> root = null; // root of tree
Integer totalWeight; // weight of tree

public huffmanTree(node e)
// post: construct a node with associated character
{
       node raiz = new node(e.frequency);
       node hoja = new node(e.ch);
              
       root = new BinaryTree<node>(raiz);
       root.setLeft(new BinaryTree<node>(hoja));
       root.setRight(empty);
       this.totalWeight = 2;
}
public huffmanTree(huffmanTree left, huffmanTree right)
{
    Integer leftFreq = left.root.val.frequency;
    Integer rightFreq = right.root.val.frequency;

    node raiz = new node((leftFreq + rightFreq));

    BinaryTree<node> leftLeaf = left.root.left;
    BinaryTree<node> rightLeaf = right.root;
    
    root = new BinaryTree<node>(raiz);
    root.left = leftLeaf;
    root.right = rightLeaf;
    
}
// pre: left and right non-null
// post: merge two trees together and merge their weights


    @Override
public int compareTo(huffmanTree other){
    return this.totalWeight.compareTo(other.totalWeight);
}
//// pre: other is non-null
//// post: return integer reflecting relation between values
//public boolean equals(Object that){
//}


// post: return true if this and that are same tree instance
public void print(){
}
// post: print out strings associated with characters in tree
protected void print(BinaryTree r, String representation){
}
// post: print out strings associated with chars in tree r,
// prefixed by representation
}